package com.hjm.project.team.teamYlPolicy.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.team.teamYlPolicy.domain.TeamYlPolicy;
import com.hjm.project.team.teamYlPolicy.service.ITeamYlPolicyService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import com.hjm.framework.web.page.TableDataInfo;

import javax.annotation.Resource;

/**
 * 团队政策中间Controller
 * 
 * @author maker-platform
 * @date 2021-04-11
 */
@Controller
@RequestMapping("/team/teamYlPolicy")
public class TeamYlPolicyController extends BaseController
{
    private String prefix = "team/teamYlPolicy";

    @Resource
    private ITeamYlPolicyService teamYlPolicyService;

    @RequiresPermissions("team:teamYlPolicy:view")
    @GetMapping()
    public String teamYlPolicy()
    {
        return prefix + "/teamYlPolicy";
    }

    /**
     * 查询团队政策中间列表
     */
    @RequiresPermissions("team:teamYlPolicy:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TeamYlPolicy teamYlPolicy)
    {
        startPage();
        List<TeamYlPolicy> list = teamYlPolicyService.selectTeamYlPolicyList(teamYlPolicy);
        return getDataTable(list);
    }

    /**
     * 导出团队政策中间列表
     */
    @RequiresPermissions("team:teamYlPolicy:export")
    @Log(title = "团队政策中间", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TeamYlPolicy teamYlPolicy)
    {
        List<TeamYlPolicy> list = teamYlPolicyService.selectTeamYlPolicyList(teamYlPolicy);
        ExcelUtil<TeamYlPolicy> util = new ExcelUtil<TeamYlPolicy>(TeamYlPolicy.class);
        return util.exportExcel(list, "teamYlPolicy");
    }

    /**
     * 新增团队政策中间
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存团队政策中间
     */
    @RequiresPermissions("team:teamYlPolicy:add")
    @Log(title = "团队政策中间", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TeamYlPolicy teamYlPolicy)
    {
        return toAjax(teamYlPolicyService.insertTeamYlPolicy(teamYlPolicy));
    }

    /**
     * 修改团队政策中间
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Integer id, ModelMap mmap)
    {
        TeamYlPolicy teamYlPolicy = teamYlPolicyService.selectTeamYlPolicyById(id);
        mmap.put("teamYlPolicy", teamYlPolicy);
        return prefix + "/edit";
    }

    /**
     * 修改保存团队政策中间
     */
    @RequiresPermissions("team:teamYlPolicy:edit")
    @Log(title = "团队政策中间", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TeamYlPolicy teamYlPolicy)
    {
        return toAjax(teamYlPolicyService.updateTeamYlPolicy(teamYlPolicy));
    }

    /**
     * 删除团队政策中间
     */
    @RequiresPermissions("team:teamYlPolicy:remove")
    @Log(title = "团队政策中间", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(teamYlPolicyService.deleteTeamYlPolicyByIds(ids));
    }
}
